<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script type="text/javascript" src="/asktao-web/js/qs-6.9.4.js"></script>
    <script type="text/javascript" src="/asktao-web/js/vue-2.6.12.js"></script>
    <script type="text/javascript" src="/asktao-web/js/axios-0.21.0.js"></script>

</head>
<body>
    <div id="app">
        <form action="" @submit.prevent="login">
            用户名：<input type="text" v-model="username"><span id="msg">{{msg}}</span><br>
            密码：<input type="password" v-model="password"><br>
            <input type="submit" value="登录">
        </form>
    </div>
    <script>
        const vm = new Vue({
            el:"#app",
            data:{
                username:"",
                password:"",
                msg:""
            },
            methods:{
                login(){
                    axios({
                        method:"post",
                        url:"/asktao-web/user/login",
                        data:Qs.stringify({
                            username : this.username,
                            password : this.password
                        })
                    }).then(resp=>{
                        console.log(resp);
                        console.log("带到了这里")
                        if (resp.data.status == "success") {
                            console.log("成功了？")
                            location.href = "/asktao-web/Celebrity/show.html";
                        } else {
                            //回显信息错误
                            this.msg = resp.data.msg;
                        }
                    })
                }
            }
        })
    </script>
</body>
</html>